package geektime.spring.springbucks.mapper;

import geektime.spring.springbucks.mybatismodel.Order;
import geektime.spring.springbucks.mybatismodel.OrderCoffee;
import org.apache.ibatis.annotations.*;

@Mapper
public interface OrderMapper {
    @Insert("insert into t_order (customer, state, create_time, update_time)"
            + "values (#{customer}, #{state}, now(), now())")
    @Options(useGeneratedKeys = true)
    Order save(Order order);

    @Update("update t_order set state=#{state},update_time=now() where id = #{id}")
    int update(Order order);

    @Delete("delete from t_order where id = #{id}")
    int delete(Order order);

    @Select("select * from t_order where id = #{id}")
    Order findById(@Param("id") Long id);
}
